package com.wise.model.content.utils;

import com.wise.framework.basic.DateTimeUtil;
import com.wise.framework.entitiesbasic.IdTimeEntity;
import com.wise.framework.session.CurrentUserId;

/**
 * Service层工具类
 *
 * @author futao
 * Created on 2019-04-16.
 */
public class ServiceTools {
    /**
     * 设置创建者(修改者)与创建(修改)时间
     *
     * @param t
     * @param <T>
     * @return
     */
    public static <T extends IdTimeEntity> T setCreateFoundationInfo(T t) {
        t.setCreatedBy(CurrentUserId.s(true));
        t.setCreationDate(DateTimeUtil.timestampNow());
        return setLastModifyInfo(t);
    }

    /**
     * 设置最后修改信息
     *
     * @param t
     * @param <T>
     * @return
     */
    public static <T extends IdTimeEntity> T setLastModifyInfo(T t) {
        t.setLastUpdateBy(CurrentUserId.s(true));
        t.setLastUpdateDate(DateTimeUtil.timestampNow());
        return t;
    }
}
